package com.oss.controller.oss;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oss.common.BaseResponse;
import com.oss.dto.oss.DeleteByIdDto;
import com.oss.dto.oss.lastprice.*;
import com.oss.dto.oss.positionmanage.DeleteDto;
import com.oss.dto.oss.positionmanage.GetByIDDto;
import com.oss.dto.oss.student.StudentUpdateDto;
import com.oss.entity.oss.LastPrice;
import com.oss.service.oss.LastPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 行情管理
 */
@RestController
@RequestMapping("/lastPrice")
public class LastPriceController {
    @Autowired
    private LastPriceService lastPriceService;

    @PostMapping("/selectByPage")
    public BaseResponse<IPage<LastPrice>> selectByPage(@RequestBody @Valid PageDto dto){
        return BaseResponse.success(lastPriceService.selectByPage(dto));
    }

    @PostMapping("/getByID")
    public BaseResponse getByID(@RequestBody @Valid GetByIDDto dto){
        return BaseResponse.success(lastPriceService.getById(dto.getId()));
    }
    @PostMapping("/add")
    public BaseResponse add(@RequestBody @Valid AddDto dto){
        return lastPriceService.add(dto);
    }
    @PostMapping("/update")
    public BaseResponse update(@RequestBody @Valid UpdateDto dto){
        return lastPriceService.updateData(dto);
    }
    @PostMapping("/delete")
    public BaseResponse<String> delete(@RequestBody @Valid DeleteByIdDto dto){
        return BaseResponse.success(lastPriceService.delete(dto.getId()));
    }
    @PostMapping("/import")
    public BaseResponse<String> importData(@RequestBody @Valid ImportDataDto dto){
        return BaseResponse.success(lastPriceService.importData(dto));
    }

}